/*
 *File Name: Overloading Operators Demo.cpp
 *Programmer Name: Manuel Cuellar
 *Date of last update: 9/30/2010
 *
 *Purpose: To instruct new coders on how to overload operators
 * simplifying vector, matrix, and other math necessities
 *
 *Basic Info: This file, is to be used for instructional purposes
 * and is in no way related to the engine. Overloading operators is very
 * important, as it makes it easier for other coders as using operators is
 * much more intuitive than calling functions for every operation.
 * To reduce files, the class will be created in the same file as our console
 * main function. The main function is found on line 75.
 *
 *UPDATES:
 *
 */

#include <iostream>
#include <conio.h>

using namespace std;

class CTest
{
private:
	//object coordinates
	int x;
	int y;
	int z;
public:
	CTest(void);
	~CTest(void);

	//Accessors and Mutators
	int getX() { return this->x; }
	void setX(int value) { this->x = value; }
	int getY() { return this->y; }
	void setY(int value) { this->y = value; }
	int getZ() { return this->z; }
	void setZ(int value) { this->z = value; }

	//overloaded + operator used to add two objects
	//Same as almost any other function. We have our return
	//Type CTest, which is the object, then we have what it is being added
	//to inside the parentheses, which is also of type CTest
	CTest operator+(const CTest& otherData) const;

};

CTest::CTest()
{
	int x = 0;
	int y = 0;
	int z = 0;
}

CTest::~CTest()
{
}

CTest CTest::operator+(const CTest& otherData) const
{
	CTest tempData;

	tempData.x = this->x + otherData.x;
	tempData.y = this->y + otherData.y;
	tempData.z = this->z + otherData.z;

	return tempData;
}

//Entry point to the main application
int main()
{
	//Create our two objects to add
	CTest first;
	CTest second;

	second.setX(1);
	second.setY(1);
	second.setZ(1);

	//Create a new object to hold result
	CTest result = first + second;

	//Display our Results
	cout << "\nResult: [" << result.getX << " " << result.getY << " " << result.getZ << "]" << endl;

	//pause
	cout << "\nPress any key to continue...";
	cin.sync();
	_getch();

	return 0;
}
